package main

import (
	"fmt"
	"net"
	"net/http"
	"os"
)

var str string
var total int

var listenAddr = ":6000"

func main() {
	getAddr()
	fmt.Println("start listen: ", listenAddr)

	http.HandleFunc("/", IndexHandler)
	http.ListenAndServe(listenAddr, nil)
}
func IndexHandler(w http.ResponseWriter, r *http.Request) {
	fmt.Fprintln(w, "hello world\n"+str+"\n"+fmt.Sprintf("%d", total))
	count()
}

func getAddr() {
	addrs, _ := net.InterfaceAddrs()
	for _, addr := range addrs {
		str += addr.String()
	}
}

func count() {
	total++
	if total > 10000 {
		os.Exit(1)
	}
}
